﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Runtime.Serialization;
using System.Collections;
using System.Data;
using System.ComponentModel;
using System.Data.OracleClient;
using ReflectionStudio.Core.Events;
using WPFExcelReport;
namespace INTEX.DataBase.Tools
{
    public partial class INTEXDBC
    {
        #region======A==============
        public void MapABFOLGE(ref DataRow dwLocal, DataRow dwData)
        {
            BlindMap(ref dwLocal, dwData);
        }

        public void MapABARTE(ref DataRow dwLocal, DataRow dwData)
        {
            BlindMap(ref dwLocal, dwData);
        }
        public void MapABAUFM(ref DataRow dwLocal, DataRow dwData)
        {
            BlindMap(ref dwLocal, dwData);
        }
            public void MapABKOPF(ref DataRow dwLocal, DataRow dwData)
        {
            BlindMap(ref dwLocal, dwData);
        }
        public void MapABPOS(ref DataRow dwLocal, DataRow dwData)
        {
            BlindMap(ref dwLocal, dwData);
        }
        public void MapICC_ABPOSFS(ref DataRow dwLocal, DataRow dwData)
        {
            BlindMap(ref dwLocal, dwData);
        }
        public void MapABPR(ref DataRow dwLocal, DataRow dwData)
        {
            BlindMap(ref dwLocal, dwData);
        }
        public void MapICC_ABPOS_MCO(ref DataRow dwLocal, DataRow dwData)
        {
            BlindMap(ref dwLocal, dwData);
        }
        
        #endregion

        #region======B==============
        public void MapBAAUF(ref DataRow dwLocal, DataRow dwData)
        {
            BlindMap(ref dwLocal, dwData);
        }
        public void MapBABST(ref DataRow dwLocal, DataRow dwData)
        {
            BlindMap(ref dwLocal, dwData);
        }

        public void MapBSSATZ(ref DataRow dwLocal, DataRow dwData)
        {
            BlindMap(ref dwLocal, dwData);
        }

        public void MapBHSATZ(ref DataRow dwLocal, DataRow dwData)
        {
            BlindMap(ref dwLocal, dwData);
        }

        public void MapBSFARB(ref DataRow dwLocal, DataRow dwData)
        {
            BlindMap(ref dwLocal, dwData);
        }

        public void MapBSGROE(ref DataRow dwLocal, DataRow dwData)
        {
            BlindMap(ref dwLocal, dwData);
        }

        public void MapBASTGA(ref DataRow dwLocal, DataRow dwData)
        {
            BlindMap(ref dwLocal, dwData);
        }
        public void MapBASTGAD(ref DataRow dwLocal, DataRow dwData)
        {
            BlindMap(ref dwLocal, dwData);
        }
        #endregion

        #region======C==============
        #endregion

        #region======D==============
        #endregion

        #region======E==============
        public void MapEKKOPF(ref DataRow dwLocal, DataRow dwData)
        {
            BlindMap(ref dwLocal, dwData);
        }
        public void MapEKPOS(ref DataRow dwLocal, DataRow dwData)
        {
            BlindMap(ref dwLocal, dwData);
        }
        public void MapEKVRECH(ref DataRow dwLocal, DataRow dwData)
        {
            BlindMap(ref dwLocal, dwData);
        }
        #endregion

        #region======F==============
        public void MapFDECK(ref DataRow dwLocal, DataRow dwData)
        {
            BlindMap(ref dwLocal, dwData);
        }
        public void MapFSSTUELI(ref DataRow dwLocal, DataRow dwData)
        {
            BlindMap(ref dwLocal, dwData);
        }
        public void MapFBST(ref DataRow dwLocal, DataRow dwData)
        {
            BlindMap(ref dwLocal, dwData);
        }
        public void MapFGBST(ref DataRow dwLocal, DataRow dwData)
        {
            BlindMap(ref dwLocal, dwData);
        }
        public void MapFBEW(ref DataRow dwLocal, DataRow dwData)
        {
            BlindMap(ref dwLocal, dwData);
        }
        public void MapFCHAR(ref DataRow dwLocal, DataRow dwData)
        {
            BlindMap(ref dwLocal, dwData);
        }
        #endregion

        #region======G==============

        public void MapGAAUF(ref DataRow dwLocal, DataRow dwData)
        {
            BlindMap(ref dwLocal, dwData);
        }
        public void MapGASTGA(ref DataRow dwLocal, DataRow dwData)
        {
            BlindMap(ref dwLocal, dwData);
        }
        public void MapGZKON(ref DataRow dwLocal, DataRow dwData)
        {
            BlindMap(ref dwLocal, dwData);
        }
        #endregion

        #region======H==============
        #endregion

        #region======K==============

        public void MapKDSTAMM(ref DataRow dwLocal, DataRow dwData)
        {
            try
            {
                BlindMap(ref dwLocal, dwData);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
        }
        public void MapKUNDVER(ref DataRow dwLocal, DataRow dwData)
        {
            try
            {
                BlindMap(ref dwLocal, dwData);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
        }
        public void MapKSLEIST(ref DataRow dwLocal, DataRow dwData)
        {
            try
            {
                BlindMap(ref dwLocal, dwData);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
        }
        
        #endregion

        #region======L==============
        public void MapLOGINFO(ref DataRow dwLocal, DataRow dwData)
        {
            try
            {
                BlindMap(ref dwLocal, dwData);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
        }
        
        #endregion

        #region======M==============
        public void MapMDECK(ref DataRow dwLocal, DataRow dwData)
        {
            BlindMap(ref dwLocal, dwData);
        }
        #endregion

        #region======P==============
        #endregion

        #region======Q==============
        public void MapQPZUORD(ref DataRow dwLocal, DataRow dwData)
        {
            BlindMap(ref dwLocal, dwData);
        }
        #endregion

        #region=====S==============
        #endregion

        #region======W==============
        //WDECK WBBST WBBEW VVLIEF VVTLIEF
        public void MapWASTAMM(ref DataRow dwLocal, DataRow dwData, bool flgExist = false, bool IsUseCurrentWS05 = false)
        {
                      //WAPROGRP WAARTGRP
            dwLocal["WABEZ"] = dwData["WABEZ"];
            dwLocal["WAPROGRP"] = dwData["WAPROGRP"];
            dwLocal["WAARTGRP"] = dwData["WAARTGRP"];
            dwLocal["WAUEBM"] = dwData["WAUEBM"];
            dwLocal["WARWBRT"] = dwData["WARWBRT"];
            dwLocal["WAFBRTL"] = dwData["WAFBRTL"];
            dwLocal["WAFBRTU"] = dwData["WAFBRTU"];
            dwLocal["WAMANDANT"] = Left(dwData["WAMANDANT"].ToString() + "  ", 2);
            dwLocal["WAART"] = Left(dwData["WAART"].ToString() + "                                         ", 20);
            dwLocal["WAVAR"] = Left(dwData["WAVAR"].ToString() + "  ", 2);
            dwLocal["WAVWART"] = Left(dwData["WAART"].ToString() + "                                         ", 20);
            dwLocal["WAVWVAR"] = Left(dwData["WAVAR"].ToString() + "  ", 2);
            dwLocal["WAKAART"] = Left(dwData["WAART"].ToString() + "                                         ", 20);
            dwLocal["WAKAVAR"] = Left(dwData["WAVAR"].ToString() + "  ", 2);
            dwLocal["WARABLOM"] = dwData["WARABLOM"].ToString();
            dwLocal["WADART"] = Left(dwData["WADART"].ToString() + "                                         ", 20);
            dwLocal["WADVAR"] = Left(dwData["WADVAR"].ToString() + "  ", 2);
            dwLocal["WASUBSTGR"] = Left(dwData["WAART"].ToString() + "                                         ", 3);
            dwLocal["WARBEM"] = Left(dwData["WARBEM"].ToString().Trim() + "                                         ", 40);
            dwLocal["WAAENB"] = dwData["WAAENB"];
            dwLocal["WAAEND"] = dwData["WAAEND"];

            dwLocal["WAFSTDLG"] = dwData["WARSTDLG"];
            dwLocal["WARSTDLG"] = dwData["WARSTDLG"];
            dwLocal["WAGFKZ"] = dwData["WAGFKZ"];
            dwLocal["WAFFERTKZ"] = dwData["WAFFERTKZ"];
            dwLocal["WAFRBST"] = dwData["WAFRBST"];


            dwLocal["WARFDDIK"] = dwData["WARFDDIK"];
            dwLocal["WARFDDIS"] = dwData["WARFDDIS"];
            dwLocal["WAFFDDIK"] = dwData["WAFFDDIK"];
            dwLocal["WAFFDDIS"] = dwData["WAFFDDIS"];
            dwLocal["WAFDDIM"] = dwData["WAFDDIM"];
            dwLocal["WARGRLFD"] = dwData["WARGRLFD"];
            dwLocal["WAFGRLFD"] = dwData["WAFGRLFD"];
            dwLocal["WARGWTOL"] = dwData["WARGWTOL"];
            dwLocal["WATSDSCH"] = dwData["WATSDSCH"];
            dwLocal["WAFGRQM"] = dwData["WAFGRQM"];
            dwLocal["WARGRQM"] = dwData["WARGRQM"];
            dwLocal["WAFSTDGW"] = dwData["WAFSTDGW"];
            dwLocal["WARSTDGW"] = dwData["WARSTDGW"];
            dwLocal["WAARTGRP"] = dwData["WAARTGRP"];
            dwLocal["WAPROGRP"] = dwData["WAPROGRP"];
            dwLocal["WARSTDLG"] = dwData["WARSTDLG"];
            dwLocal["WAFSTDLG"] = dwData["WAFSTDLG"];
            dwLocal["WABIND"] = Left(dwData["WABIND"].ToString() + "               ", 15);
            dwLocal["WAEINZNR"] = Left(dwData["WAEINZNR"].ToString() + "                ", 15);
            dwLocal["WALAEAEND"] = dwData["WALAEAEND"];
            dwLocal["WAGASTA"] = "V";
            dwLocal["WARSTAKZ"] = "A";

            if (dwData["WARFERTKZ"].ToString() != "E")
            {
                dwLocal["WARFERTKZ"] = dwData["WARFERTKZ"];
                dwLocal["WAGASTA"] = dwData["WAGASTA"];
                dwLocal["WAMASTA"] = dwData["WAMASTA"];
                dwLocal["WAKESTA"] = dwData["WAKESTA"];
                dwLocal["WAMATPRF"] = dwData["WAMATPRF"];
                dwLocal["WABRTPRF"] = dwData["WABRTPRF"];
                dwLocal["WASTKGP"] = dwData["WASTKGP"];
                dwLocal["WASCHLIP"] = dwData["WASCHLIP"];
                dwLocal["WASCHLIA"] = dwData["WASCHLIA"];
                dwLocal["WALIEFNR"] = dwData["WALIEFNR"];
                dwLocal["WAEG"] = dwData["WAEG"];
            }  
            if (IsUseCurrentWS05
                && flgExist)
            { 
            }
            else
            {
                #region=====else==========  
                dwLocal["WABEZ"] = Left(dwData["WABEZ"].ToString().Trim() + "                                         ", 40);
                dwLocal["WANEUB"] = dwData["WANEUB"].ToString();
                dwLocal["WANEUD"] = dwData["WANEUD"].ToString();   
                #endregion
            }
        }
        
        public void MapWAFARBEN(ref DataRow dwLocal, DataRow dwData)
        {
            BlindMap(ref dwLocal, dwData);
        }
        public void MapWAPROF(ref DataRow dwLocal, DataRow dwData)
        {
            BlindMap(ref dwLocal, dwData);
        }
        public void MapWASTPASS(ref DataRow dwLocal, DataRow dwData)
        {
            BlindMap(ref dwLocal, dwData);
        }
        public void MapWBBST(ref DataRow dwLocal, DataRow dwData)
        {
            BlindMap(ref dwLocal, dwData);
        }
        public void MapWBBEW(ref DataRow dwLocal, DataRow dwData)
        {
            BlindMap(ref dwLocal, dwData);
        }
        public void MapWBDAT(ref DataRow dwLocal, DataRow dwData)
        {
            BlindMap(ref dwLocal, dwData);
        }
        public void MapWDECK(ref DataRow dwLocal, DataRow dwData)
        {
            BlindMap(ref dwLocal, dwData);
        }
        public void MapWGBST(ref DataRow dwLocal, DataRow dwData)
        {
            BlindMap(ref dwLocal, dwData);
        }
        public void MapWTSCHUSS(ref DataRow dwLocal, DataRow dwData)
        {
            BlindMap(ref dwLocal, dwData);
        }
        public void MapWTPASS(ref DataRow dwLocal, DataRow dwData)
        {
            BlindMap(ref dwLocal, dwData);
        }
        public void MapWTSAER(ref DataRow dwLocal, DataRow dwData)
        {
            BlindMap(ref dwLocal, dwData);
        }
        public void MapWTGEW(ref DataRow dwLocal, DataRow dwData)
        {
            BlindMap(ref dwLocal, dwData);
        }
        public void MapWTEINZ(ref DataRow dwLocal, DataRow dwData)
        {
            BlindMap(ref dwLocal, dwData);
        }

        public void MapWASTKE(ref DataRow dwLocal, DataRow dwData)
        {
            BlindMap(ref dwLocal, dwData);
        }

        public void MapWASTGA(ref DataRow dwLocal, DataRow dwData)
        {
            BlindMap(ref dwLocal, dwData);
        }
        #endregion

        #region======V==============
        public void MapVKKOPF(ref DataRow dwLocal, DataRow dwData)
        {
            try
            {
                BlindMap(ref dwLocal, dwData);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
        }
        public void MapVKPOS(ref DataRow dwLocal, DataRow dwData)
        {
            try
            {
                BlindMap(ref dwLocal, dwData);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
        }
        public void MapVVLIEF(ref DataRow dwLocal, DataRow dwData)
        {
            BlindMap(ref dwLocal, dwData);
        }
        public void MapVAFARBEN(ref DataRow dwLocal, DataRow dwData)
        {
            BlindMap(ref dwLocal, dwData);
        }
        
        public void MapVVTLIEF(ref DataRow dwLocal, DataRow dwData)
        {
            BlindMap(ref dwLocal, dwData);
        }
        public void MapVVPACK(ref DataRow dwLocal, DataRow dwData)
        {
            BlindMap(ref dwLocal, dwData);
        }
        
        #endregion
        #region======V==============
        public void MapICC_XDECK(ref DataRow dwLocal, DataRow dwData)
        {
            BlindMap(ref dwLocal, dwData);
        }
        #endregion
        
        /// <summary>
        /// /注意一些默认值的取值问题，需要在一个特别的客户进行设定。比如客户9999专门用于产生此类订单。
        /// </summary>
        /// <param name="dwLocal"></param>
        /// <param name="dwData"></param>


        public void BlindMap(ref DataRow dwLocal, DataRow dwData)
        {
            foreach (DataColumn dc in dwLocal.Table.Columns)
            {
                string colum = dc.ColumnName;
                if (dwData.Table.Columns.Contains(colum))
                {
                    if (dc.DataType.ToString() == "System.Byte[]")
                    {
                        dwLocal[colum] = System.Text.Encoding.Default.GetBytes(dwData[colum].ToString());
                    }
                    else
                    {
                        dwLocal[colum] = dwData[colum];
                    }
                }
            }
        }

        public void MapAPZUORD(ref DataRow dwLocal, DataRow dwData)
        {
            BlindMap(ref dwLocal, dwData);
        }
        public void MapGSCOLOR(ref DataRow dwLocal, DataRow dwData)
        {
            BlindMap(ref dwLocal, dwData);
        }

        #region===ICC============
         //ICC_FOLDERS;ICC_MENUDEF; ICC_FUNCTIONS
        public void MapICC_FOLDERS(ref DataRow dwLocal, DataRow dwData)
        {
            BlindMap(ref dwLocal, dwData);
        }
        public void MapICC_MENUDEF(ref DataRow dwLocal, DataRow dwData)
        {
            BlindMap(ref dwLocal, dwData);
        }
        public void MapICC_FUNCTIONS(ref DataRow dwLocal, DataRow dwData)
        {
            BlindMap(ref dwLocal, dwData);
        }
        #endregion
    }
}
